<?php

/**
 * provides functions for creating an easyui progressbar
 * @author simon.ungerboeck
 *
 */
class ProgressBar {
	private $id;
	private $width;
	
	/************************************************************************
	 ************************** PUBLIC FUNCTIONS ****************************
	************************************************************************/
	
	
	public function __construct($id = null){
		$this->id = $id;
	}
	
	
	/**
	 * creates the progressbar
	 * @return 		string		$output
	 */
	public function create(){
		$output = '<div class="easyui-progressbar" ';
		$output .= (isset($this->id) ? 'id="' . $this->id . '" ' : '');
		$output .= (isset($this->width) ? 'style="width: ' . $this->width . 'px" ' : '');
		$output .= '></div>';
		return $output;
	}
	
	
	/**
	 * creates the progressbar
	 * @return 		string
	 */
	public function __toString(){
		return $this->create();
	}
	
	/************************************************************************
	 **************************** GETTER / SETTER ***************************
	************************************************************************/
	
	
	
	public function setId($id){
		$this->id = $id;
	}
	
	public function setWidth($width){
		if (is_numeric($width))
			$this->width = $width;
		else throw new \Exception('width must be a numeric value');
	}
	
	public function getId(){
		return $this->id;
	}
	
	public function getWidth(){
		return $this->width;
	}
	
}
